<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>编辑知识</title>
    <!-- (可以复用 add_product.html 的样式) -->
    <style>
        body { font-family: -apple-system, sans-serif; background-color: #f4f4f8; margin: 0; padding: 20px; display: flex; justify-content: center; }
        .container { width: 100%; max-width: 600px; background: #fff; padding: 30px; border-radius: 12px; box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
        h1 { text-align: center; color: #333; }
        .form-group { margin-bottom: 20px; }
        label { display: block; margin-bottom: 8px; font-weight: bold; color: #555; }
        input[type="text"], select, textarea { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 5px; font-size: 1em; box-sizing: border-box; }
        textarea { min-height: 150px; resize: vertical; }
        button { width: 100%; padding: 12px; background-color: #28a745; color: white; border: none; border-radius: 5px; font-size: 1.1em; cursor: pointer; transition: background-color 0.3s; }
        button:hover { background-color: #218838; }
        .nav-link { display: block; text-align: center; margin-top: 20px; color: #007bff; text-decoration: none; }
    </style>
</head>
<body>
    <div class="container">
        <h1>编辑知识: {{ product['name'] }}</h1>
        <form method="POST" action="{{ url_for('edit_product', product_id=product['id']) }}">
            <div class="form-group">
                <label for="name">商品名称</label>
                <input type="text" id="name" name="name" value="{{ product['name'] }}" required>
            </div>
            <div class="form-group">
                <label for="category">商品分类</label>
                <select id="category" name="category" required>
                    <option value="laptop" {% if product['category'] == 'laptop' %}selected{% endif %}>笔记本</option>
                    <option value="keyboard" {% if product['category'] == 'keyboard' %}selected{% endif %}>键盘</option>
                    <option value="mouse" {% if product['category'] == 'mouse' %}selected{% endif %}>鼠标</option>
                    <option value="general" {% if product['category'] == 'general' %}selected{% endif %}>通用</option>
                </select>
            </div>
            <div class="form-group">
                <label for="description">商品描述 (支持Markdown)</label>
                <textarea id="description" name="description" required>{{ product['description'] }}</textarea>
            </div>
            <button type="submit">更新知识</button>
        </form>
        <a href="{{ url_for('manage_knowledge') }}" class="nav-link">返回知识库管理</a>
    </div>
</body>
</html>